var dynDiv = null;
var msgBox = null;
var timeOut  = null;
var widthx = 50;
var heighty = 20;
var x ;
var y;
var path;

function OpenDialog(src,width,height,path) { 

return window.showModalDialog(src,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;dialogLeft:"+((screen.availWidth-width)/2)+"px;dialogTop:"+((screen.availHeight-height)/2)+"px;scroll:yes;resizable:yes");
}
function changeUnitPxToInt(val){
	 val = val.replace("px","");
	 val = parseInt(val);
	 return val;
}
function createDynamicDialog(obj,width,height,src){
	x = width;
	y = height;
	path = src;
	dynDiv 	 = document.createElement("div");
	dynDiv.className="msg";
	dynDiv.style.left = obj.offsetLeft;
	dynDiv.style.top  = obj.offsetTop;
	dynDiv.style.width = obj.offsetWidth;
	dynDiv.style.height = obj.offsetHeight;
	document.body.appendChild(dynDiv);
	if(timeOut!=null){
			clearTimeout(timeOut);
			timeOut = null;
	}
	delayShow();

}
function delayShow(){
	dynDiv.style.width  = widthx ;
	dynDiv.style.height = heighty;
	heighty = heighty+50;
	widthx  = widthx +50;
	if( heighty >= changeUnitPxToInt(window.dialogHeight)
		||widthx >=changeUnitPxToInt(window.dialogWidth) ){
		if(timeOut!=null){
			clearTimeout(timeOut);
			timeOut = null;
		}
		dynDiv.style.width  = window.dialogWidth;
		dynDiv.style.height = window.dialogHeight;
		dynDiv.style.left = 0;
		dynDiv.style.top  = 0;
		createOtherDefineDialog(x,y,path);
		return;
	}
	timeOut = setTimeout("delayShow()",100);
}
function createOtherDefineDialog(width,height,path){
	if(msgBox==null){
		var wbobj 	 = document.createElement("div");
		var titleObj = document.createElement("div");
		var content  = document.createElement("div");
		var iframeObj = document.createElement("iframe");
		var close = document.createElement("img");
		wbobj.className = "msg-box";
		wbobj.setAttribute("id","dialog");
		wbobj.style.width  = width;
		wbobj.style.height = height;
		wbobj.style.left = (changeUnitPxToInt(window.dialogWidth)-width)/2;
		wbobj.style.top = (changeUnitPxToInt(window.dialogHeight)-height)/2;
		titleObj.style.width =width;
		titleObj.style.height = 20;
		titleObj.style.paddingRight ="10px";
		titleObj.style.paddingTop ="2px";
		titleObj.setAttribute("align","right");
		titleObj.style.backgroundColor="#E5ECF5";
		close.src = "../images/dialog/title-close.gif";
		close.onclick = closeDialog;
		content.style.width = width;
		content.style.height = height-20;
		iframeObj.src = path;
		iframeObj.style.width = width;
		iframeObj.style.height= "100%"
		iframeObj.style.margin="0px";
		iframeObj.setAttribute("border","0");
		iframeObj.setAttribute("frameborder","0");
		iframeObj.setAttribute("scrolling","auto");
		titleObj.appendChild(close);
		content.appendChild(iframeObj);
		wbobj.appendChild(titleObj);
		wbobj.appendChild(content);
		document.body.appendChild(wbobj);
		msgBox = wbobj
		//alert(dynDiv.innerHTML);
	}
}
function closeDialog(){
	dynDiv.removeNode(true);
	msgBox.removeNode(true);
	dynDiv = null;
	msgBox = null;
	heighty = 0;
	widthx = 0;
	x=0;
	y=0;
	path=null;
	
}
function createDefineDialog(width,height){
	var divObj1 = document.createElement("div");
	divObj1.className="msg-box";
	var divObj2    = document.createElement("div");
	var divTLeft   = document.createElement("div");
	var divTCenter = document.createElement("div");
	var divTRight  = document.createElement("div");
	var divblank   = document.createElement("div");
	divObj2.className="msg-box-title";
	divTLeft.className="msg-box-title-left";
	divTCenter.className="msg-box-title-center";
	divTRight.className="msg-box-title-right";
	divblank.className="msg-box-blank";
	divObj2.appendChild(divTLeft);
	divObj2.appendChild(divTCenter);
	divObj2.appendChild(divTRight);
	divObj2.appendChild(divblank);
	var divObj3    = document.createElement("div");
	var divCLeft   = document.createElement("div");
	var divCCenter = document.createElement("div");
	var divCRight  = document.createElement("div");
	divCLeft.className="msg-box-content-left";
	divCCenter.className="msg-box-content";
	divCRight.className="msg-box-content-right";
	divObj3.appendChild(divCLeft);
	divObj3.appendChild(divCCenter);
	divObj3.appendChild(divCRight);
	var divObj4    = document.createElement("div");
	var divBLeft   = document.createElement("div");
	var divBCenter = document.createElement("div");
	var divBRight  = document.createElement("div");
	divBLeft.className="btm-left";
	divBCenter.className="btm-center";
	divBRight.className="btm-right";
	divObj4.appendChild(divBLeft);
	divObj4.appendChild(divBCenter);
	divObj4.appendChild(divBRight);
	divObj1.appendChild(divObj2);
	divObj1.appendChild(divObj3);
	divObj1.appendChild(divObj4);
	return divObj1;
}